package dao;

import connection.connectionFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import model.Faixasalarial;

public class FaixaSalarialDao {
            
    Session session;
    Transaction tx; 
    
    public void salvar(Faixasalarial faixasalarial)
    {
      try
      {
          session = new connectionFactory().getSessionFactory();
          tx =  session.beginTransaction();
          session.save(faixasalarial);
          tx.commit();
          session.close();
            
      }
      catch(Exception e)
      {
           e.printStackTrace();
           tx.rollback();
           session.close();
      }
    } 
    
    public void alterar(Faixasalarial faixasalarial)
    {
      try
      {
          session = new connectionFactory().getSessionFactory();
          tx =  session.beginTransaction();
          session.update(faixasalarial);
          tx.commit();
          session.close();
            
      }
      catch(Exception e)
      {
           e.printStackTrace();
           tx.rollback();
           session.close();
      }
    }  
    
    public void excluir(Faixasalarial faixasalarial)
    {
      try
      {
          session = new connectionFactory().getSessionFactory();
          tx =  session.beginTransaction();
          session.delete(faixasalarial);
          tx.commit();
          session.close();
            
      }
      catch(Exception e)
      {
           e.printStackTrace();
           tx.rollback();
           session.close();
      }
    } 
}

